<?php
class mysql{
    //连接服务器、数据库以及执行SQL语句的类库
    public $database;
    public $server_username;
    public $server_userpassword;
    function mysqli()
  	{  //构造函数初始化所要连接的数据库
       $this->server_username="root";
       $this->server_userpassword="root1234";
       }//end mysqli()
	function link($database)
  	{  //连接服务器和数据库
       //设置所有连接的数据库
        if ($database==""){
            $this->database="smallT";
            }else{
            $this->database=$database;
            }
        //连接服务器和数据库
     	if(@$id=mysqli_connect('localhost',"root","root1234")){
          if(!mysqli_select_db($id, $this->database)){
		       echo "数据库连接错误！！！";
               exit;
               }
 	       }else{
               echo "服务器正在维护中，请稍后重试！！！";
               exit;
      	   }
	}//end link($database)
	function excu($query)
    {     //执行SQL语句
	      $result=mysqli_query($id=mysqli_connect('localhost',"root","root1234",$this->database), $query) or die(mysqli_error($id));
    		   if($result=mysqli_query($id=mysqli_connect('localhost',"root","root1234",$this->database), $query)){
				
				return $result;
        	}else{
             	echo "sql语句执行错误！！！请重试!!!";
				
       		    exit;
        	}   
    } //end  exec($query)
} //end class mysql
?>
